import React from "react";
import "../css/Borard.css";
import eventEmitter from "./event";
export default class Borard extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            messages:[],
        }
    }

    //创建
    componentDidMount(){
        //监听事件
        eventEmitter.addListener("sendMessageTooBoard",(messagea)=>{
            console.log(messagea);
            this.state.messages.push(messagea);
            this.setState({
                messages:this.state.messages
            })
        })
    }
    render(){
        return(
            <div className="borard_container">
                {
                    this.state.messages.map((element,index)=>{
                 return <div className="borard_wrapper">
                            <div>{element.content}</div>
                            <div>{element.date}</div>
                        </div>
                       
                    })
                }
            </div>
        )
    }
}